<%--
  Created by IntelliJ IDEA.
  User: 武露斌
  Date: 2021/11/4
  Time: 15:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="../../js/jquery-1.8.2.min.js"></script>
    <script src="../../js/fileupload.js"></script>
    <link rel="stylesheet" href="../../css/css.css">
    <link rel="stylesheet" href="../../css/img.css">
</head>
<body>

<h1>添加页面</h1>
<form>

    收货日期：<input type="text" name="datime"><br>
    收货单号：<input type="text" name="danhao"><br>

<%--    优先级：<input type="text" name="priority"><br>--%>
    优先级：<select name="priority">
    <option value="">请选择</option>
    <option value="1">一级</option>
    <option value="2">二级</option>
    <option value="3">三级</option>
    <option value="4">四级</option>
</select><br>
    状态：
    <select name="states">
        <option value="">请选择</option>
        <option value="已完成">已完成</option>
        <option value="计划中">计划中</option>
        <option value="执行中">执行中</option>
        <option value="已取消">已取消</option>
    </select>
    <br>
    备注：<input type="text" name="beizhu"><br>
    客户发货单列表：<input type="text" name="fahuodan"><br>
    制单人工号：<input type="text" name="zdrenhao"><br>
    制单人：<input type="text" name="zdren"><br>
    制单时间：<input type="text" name="zdtime"><br><br><br>
    收货附件：
<%--    <input type="text" name="imgs">--%>
    <div class="photoUpLoad" >
        <input type="file"   class="photo" name="photo" accept="image/*"><span class="cross">+</span>
        <img src="" alt="" class="photoEcho">
    </div>
    <br><br>
    重量：<input type="text" name="weight"><br>
    客户：
    <select name="cid">
        <option value="">请选择客户</option>
    </select>
    <br>
    用户：
    <select name="uid">
        <option value="">请选择用户</option>
    </select>
    <br>

</form>
<input type="button" value="添加" onclick="add()">
</body>
</html>

<script>

    $.ajax({
        url:"listc.do",
        type:"post",
        dataType:"json",
        success:function (data) {
            for (let i = 0; i <data.length ; i++) {
                $("[name='cid']").append(' <option value="'+data[i].cid+'">'+data[i].cname+'</option>')
            }
        }
    })

    $.ajax({
        url:"listu.do",
        type:"post",
        dataType:"json",
        success:function (data) {
            for (let i = 0; i <data.length ; i++) {
                $("[name='uid']").append(' <option value="'+data[i].uid+'">'+data[i].uname+'</option>')
            }
        }
    })

    function add() {
        var formData = new FormData($("form")[0]);

        $.ajax({
            url:"add.do",
            data:formData,
            type:"post",
            dataType:"json",
            success:function (data) {
                if (data>0){
                    alert("添加成功")
                    location="list.do"
                }else{
                    alert("添加失败")
                }
            },processData:false,contentType:false
        })
    }

</script>














